import request from '@/axios'
import type { ListParams, Response } from '@/api/api'

export interface Row {
  id: number
  name: string
  role_key: string
  role_sort: string
  status: string
  remark: string
  menu_ids: string
}

export interface FormData {
  id?: number
  name: string
  role_key: string
  role_sort: string
  status: string
  remark: string
  menu_ids: string
}
// 角色列表
export const getListApi = (data: ListParams): Promise<Response<Row>> => {
  return request.post({ url: '/user/role/list', data })
}
// 角色列表新增
export const createApi = (data: Partial<FormData>): Promise<IResponse> => {
  return request.post({ url: '/user/role/create', data })
}
// 角色列表编辑
export const modifyApi = (data: Partial<FormData>): Promise<IResponse> => {
  return request.post({ url: '/user/role/modify', data })
}
// 角色列表删除
export const delUserApi = (data: { id: string }): Promise<IResponse> => {
  return request.post({ url: '/user/role/del', data })
}
// 角色列表状态修改
export const updateStatusApi = (data: { status: string; id: string }): Promise<IResponse> => {
  return request.post({ url: '/user/role/modify_status', data })
}
